package com.member.shop.service.impl;

import java.util.Arrays;
import java.util.List;

import com.member.common.utils.DateUtils;

import javax.annotation.Resource;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.member.shop.dto.MessageStatDto;
import org.springframework.stereotype.Service;
import com.member.shop.mapper.SysBizMessageMapper;
import com.member.shop.domain.SysBizMessage;
import com.member.shop.service.ISysBizMessageService;

/**
 * 消息Service业务层处理
 *
 * @author lixinchen
 * @date 2025-01-08
 */
@Service
public class SysBizMessageServiceImpl extends ServiceImpl<SysBizMessageMapper, SysBizMessage> implements ISysBizMessageService {
    @Resource
    private SysBizMessageMapper sysBizMessageMapper;

    /**
     * 查询消息
     *
     * @param id 消息主键
     * @return 消息
     */
    @Override
    public SysBizMessage selectSysBizMessageById(Long id) {
        return sysBizMessageMapper.selectById(id);
    }

    /**
     * 查询消息列表
     *
     * @param queryWrapper 消息
     * @return 消息
     */
    @Override
    public List<SysBizMessage> selectSysBizMessageList(LambdaQueryWrapper<SysBizMessage> queryWrapper) {
        return sysBizMessageMapper.selectList(queryWrapper);
    }

    @Override
    public List<SysBizMessage> selectSysBizMessageList(SysBizMessage sysBizMessage) {
        return sysBizMessageMapper.selectSysBizMessageList(sysBizMessage);
    }

    /**
     * 新增消息
     *
     * @param sysBizMessage 消息
     * @return 结果
     */
    @Override
    public int insertSysBizMessage(SysBizMessage sysBizMessage) {
        sysBizMessage.setCreateTime(DateUtils.getNowDate());
        return sysBizMessageMapper.insert(sysBizMessage);
    }

    /**
     * 修改消息
     *
     * @param sysBizMessage 消息
     * @return 结果
     */
    @Override
    public int updateSysBizMessage(SysBizMessage sysBizMessage) {
        sysBizMessage.setUpdateTime(DateUtils.getNowDate());
        return sysBizMessageMapper.updateById(sysBizMessage);
    }

    /**
     * 批量删除消息
     *
     * @param ids 需要删除的消息主键
     * @return 结果
     */
    @Override
    public int deleteSysBizMessageByIds(Long[] ids) {
        return sysBizMessageMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除消息信息
     *
     * @param id 消息主键
     * @return 结果
     */
    @Override
    public int deleteSysBizMessageById(Long id) {
        return sysBizMessageMapper.deleteById(id);
    }

    @Override
    public List<MessageStatDto> getStatListByUserId(Long userId, Long tenantId) {
        return sysBizMessageMapper.getStatListByUserId(userId, tenantId);
    }
}
